The Thread Manager allows you to install a custom context-switching function to supplement the context information that the Thread Manager saves when it switches control between one thread and another. This section describes how to install a custom context-switching function and use it in conjunction with the default context-switching mechanism.
You install a custom context-switching function with the SetThreadSwitcher function. You assign a custom switching function separately to each thread. However, because you also pass a parameter containing thread specific information, you can define a single switching function to assign to all threads and use this parameter to pass specific information to each thread.
The Thread Manager calls the custom context-switching function, MyThreadSwitchProc , whenever the thread it is assigned to is scheduled. Because it is a `switcher inner' it is called just before the code starts executing. The Thread Manager calls a `switcher outer' custom switching function just after the code in the thread stops executing. Figure 4 shows when the Thread Manager calls each type of custom context-switching function.
Figure 4 Custom context-switching function